#include "framemovieplugin.h"

class FrameMoviePlugin;

K_PLUGIN_FACTORY( KDCMenuPluginFactory, registerPlugin< FrameMoviePlugin >(); )
K_EXPORT_PLUGIN( KDCMenuPluginFactory( "FrameMoviePlugin" ) )

#include "framemoviejob.h"

#include <interfaces/kdcapplicationinterface.h>
KDCApplicationInterface *gAppInterface;

FrameMoviePlugin::FrameMoviePlugin( QObject *parent, const QVariantList &args ) : FramePluginInterface( parent ), pInfo( KPluginInfo("framemovieplugin.desktop", "services") )
{
	Q_UNUSED( args );
	gAppInterface = NULL;
}

FrameMoviePlugin::~FrameMoviePlugin()
{

}

const KPluginInfo& FrameMoviePlugin::info() const
{
	return pInfo;
}

QPixmap FrameMoviePlugin::preview() const
{
	QString path;
	if ( gAppInterface )
		path = gAppInterface->applicationDataDir() + "/frames/frame_movie_thumb.png";
	return QPixmap( path );
}

QPixmap FrameMoviePlugin::create( const QPixmap &aInput, int aWidth, int aHeight, QString &aError ) const
{
	FrameMovieJob job( aInput );
	if ( job.exec() )
		return job.resultFrame();
	aError = job.errorText();
	return QPixmap();
}

KDCFrameJobInterface* FrameMoviePlugin::createJob( const QPixmap &aInput, int aWidth, int aHeight ) const
{
	return new FrameMovieJob( aInput );
}

void FrameMoviePlugin::setApplicationInterface( KDCApplicationInterface* aInterface )
{
	gAppInterface = aInterface;
}
